c41b15c5dfa6916e607ce34383c3dfcddca2f94d
8 * SpecialShortpages extends QueryPage. It is used to return the shortest
9 * pages in the database.
10 * @ingroup SpecialPage
12 class ShortPagesPage
extends QueryPage
{
19 * This query is indexed as of 1.5
21 function isExpensive() {
25 function isSyndicated() {
30 global $wgContentNamespaces;
32 $dbr = wfGetDB( DB_SLAVE
);
33 $page = $dbr->tableName( 'page' );
34 $name = $dbr->addQuotes( $this->getName() );
36 $forceindex = $dbr->useIndexClause("page_len");
38 if ($wgContentNamespaces)
39 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
41 $nsclause = "page_namespace = " . NS_MAIN
;
44 "SELECT $name as type,
45 page_namespace as namespace,
48 FROM $page $forceindex
49 WHERE $nsclause AND page_is_redirect=0";
52 function preprocessResults( $db, $res ) {
53 # There's no point doing a batch check if we aren't caching results;
54 # the page must exist for it to have been pulled out of the table
55 if( $this->isCached() ) {
56 $batch = new LinkBatch();
57 while( $row = $db->fetchObject( $res ) )
58 $batch->add( $row->namespace, $row->title
);
60 if( $db->numRows( $res ) > 0 )
61 $db->dataSeek( $res, 0 );
65 function sortDescending() {
69 function formatResult( $skin, $result ) {
70 global $wgLang, $wgContLang;
71 $dm = $wgContLang->getDirMark();
73 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
75 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
77 $hlink = $skin->linkKnown(
81 array( 'action' => 'history' )
83 $plink = $this->isCached()
84 ?
$skin->link( $title )
85 : $skin->linkKnown( $title );
86 $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value
) ) );
88 return $title->exists()
89 ?
"({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
90 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
97 function wfSpecialShortpages() {
98 list( $limit, $offset ) = wfCheckLimits();
100 $spp = new ShortPagesPage();
102 return $spp->doQuery( $offset, $limit );